"""
View module for the project wizard  
"""

import wx
import wx.wizard as wiz
import epistasis_wizard

########################################################################
class TitledPage(wiz.WizardPageSimple):
    """"""

    #----------------------------------------------------------------------
    def __init__(self, parent, title):
        """Constructor"""
        wiz.WizardPageSimple.__init__(self, parent)

        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
 
        title = wx.StaticText(self, -1, title)
        title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
        sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
        #sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)


class ProjectWizardPage(wiz.WizardPageSimple):
    """"""
 
    #----------------------------------------------------------------------
    def __init__(self, parent, mypage):
        """Constructor"""
        wiz.WizardPageSimple.__init__(self, parent)


        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        self.content = mypage(self)
        #def self.content.onRadioOpenProject(self.event):
        
        sizer.Add(self.content, 1, wx.EXPAND, 5 )		
        #sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)
    
    
    
    
    
#def AddPage(parent, mypage):
    
#    new_page = wiz.WizardPageSimple(parent)
         
    
#    sizer = wx.BoxSizer(wx.VERTICAL)
#    new_page.SetSizer(sizer)
#    p = mypage(new_page)
#    sizer.Add(p, 1, wx.EXPAND, 5 )        
#    sizer.Add(wx.StaticLine(new_page, -1), 0, wx.EXPAND|wx.ALL, 5)
 

#----------------------------------------------------------------------


class ProjectWizardView(wx.wizard.Wizard):
    start_page = None
    def __init__(self,parent, style):
        
        #wizard = wx.wizard.Wizard(None, -1, "Simple Wizard")
        wx.wizard.Wizard.__init__(self, parent, -1, "Import data wizard", style=style)
        
        import epistasis_wizard
        
        #page1 = AddPage(wizard, project_settings_page)
        #page2 = AddPage(wizard, import_genotypes_page)
        #page3 = AddPage(wizard, import_phenotypes_page)
        #page4 = TitledPage(wizard, "Page 4")
        
        #self.init_page = ProjectWizardPage(self, epistasis_wizard.init_page)
        
        self.project_settings_page = ProjectWizardPage(self, epistasis_wizard.wiz_settings_page)
 #       self.import_subjects_page = ProjectWizardPage(self, epistasis_wizard.wiz_subject_page)    
        self.import_genotypes_page = ProjectWizardPage(self, epistasis_wizard.wiz_genotype_page)
        self.import_phenotypes_page = ProjectWizardPage(self, epistasis_wizard.wiz_phenotype_page)    
        self.import_classes_page = ProjectWizardPage(self, epistasis_wizard.wiz_class_page)    
        
        #self.import_status_page = epistasis_wizard.import_status_page
        
        #wx.wizard.WizardPageSimple.Chain(self.init_page, self.project_settings_page)
        wx.wizard.WizardPageSimple.Chain(self.project_settings_page, self.import_genotypes_page)
  #      wx.wizard.WizardPageSimple.Chain(self.import_subjects_page, self.import_genotypes_page)
        
        wx.wizard.WizardPageSimple.Chain(self.import_genotypes_page, self.import_phenotypes_page)
        wx.wizard.WizardPageSimple.Chain(self.import_phenotypes_page, self.import_classes_page)
        #wizard.FitToPage(page1)
        #wizard.RunWizard(page1)
        #wizard.Destroy()
        #self.SetPageSize(wx.Size(600,400))
        self.FitToPage(self.project_settings_page)
        
        #self.start_page = page1
   #    self.RunWizard(page1)
    #   self.Destroy()
        
        
            # Connect Events
        self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGING, self.OnWizardChangingPage)
        self.Bind(wx.wizard.EVT_WIZARD_PAGE_CHANGED, self.OnWizardChangedPage)
        self.Bind(wx.wizard.EVT_WIZARD_FINISHED, self.OnWizardFinished)
        self.Bind(wx.wizard.EVT_WIZARD_CANCEL, self.OnWizardCancel)
        
        #self.init_page.content.radioBtn_new_prj.Bind( wx.EVT_RADIOBUTTON, self.onRadioNewProject )
        #self.init_page.content.radioBtn_open_prj.Bind( wx.EVT_RADIOBUTTON, self.onRadioOpenProject )
        #self.init_page.content.radioBtn_recent_prj.Bind( wx.EVT_RADIOBUTTON, self.onRadioRecentProject )
        
        #self.import_subjects_page.content.subject_file_picker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnSubjectFileSelected )
        self.import_genotypes_page.content.genotype_file_picker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnGenotypeFileSelected )
        self.import_phenotypes_page.content.phenotype_file_picker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnPhenotypeFileSelected )
        #self.import_classes_page.content.class_file_picker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnClassFileSelected )
        #self.import_classes_page.content.partition_file_picker.Bind( wx.EVT_FILEPICKER_CHANGED, self.OnPartitionFileSelected )
        
        self.import_classes_page.content.partition_radio_button.Bind( wx.EVT_RADIOBUTTON, self.OnPartionRadioBtn )
    
        self.import_classes_page.content.class_radio_button.Bind( wx.EVT_RADIOBUTTON, self.OnClassRadioBtn )
        
        # Connect Events
        self.import_classes_page.content.import_btn.Bind(wx.EVT_BUTTON, self.OnImportPartitionBtn)
        #self.import_classes_page.content.stop_btn.Bind(wx.EVT_BUTTON, self.OnStopImportBtn)
        
    # Virtual event handlers, overide them in your derived class
    
    def OnGenotypeFileSelected(self, event ):
        event.Skip()
    
    def OnPhenotypeFileSelected(self, event ):
        event.Skip()
    
    def OnPartionRadioBtn(self, event):
        event.Skip()
    
    def OnClassRadioBtn(self, event):
        event.Skip()

    def OnPartitionFileSelected(self, event ):
        event.Skip()
    
    def OnClassFileSelected(self, event ):
        event.Skip()

    def test(self, event ):
        event.Skip()
        
    def OnWizardFinished(self, event):
        event.Skip()
    
    def OnWizardCancel(self, event):
        event.Skip()
    
    def OnWizardChangedPage(self, event):
        event.Skip()
    
    def OnWizardChangingPage(self, event):
        event.Skip()

    



    
    def __del__( self ):
        pass
        
    def run(self):
        self.RunWizard(self.start_page)
        self.Destroy()

        

#def main():
#    """"""
    
    #wizard = wx.wizard.Wizard(None, -1, "Simple Wizard")
    #import epistasis_wizard

    #project_settings_page = epistasis_wizard.wiz_settings_page
    #import_genotypes_page = epistasis_wizard.wiz_genotype_page
    #import_phenotypes_page = epistasis_wizard.wiz_phenotype_page 
    
    #page1 = AddPage(wizard, project_settings_page)
    #page2 = AddPage(wizard, import_genotypes_page)
    ##page3 = AddPage(wizard, import_phenotypes_page)
    #page4 = TitledPage(wizard, "Page 4")
 
    #wx.wizard.WizardPageSimple.Chain(page1, page2)
    #wx.wizard.WizardPageSimple.Chain(page2, page3)
    #wx.wizard.WizardPageSimple.Chain(page3, page4)
    #wizard.FitToPage(page1)
 
    #wizard.RunWizard(page1)
 
    #wizard.Destroy()
 
#----------------------------------------------------------------------
if __name__ == "__main__":
 #   app = wx.App(False)
 #   app.MainLoop()
 
    app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
    w = ProjectWizardView(parent=None) # A Frame is a top-level window.
    #w.Show(True)     # Show the frame.
    w.run()
    
    app.MainLoop()
 
